package de.scs.ui;

import java.awt.Component;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class FrameTemplate extends JFrame
{
  /**
     * 
     */
  private static final long serialVersionUID = 5483701550568171130L;

  public FrameTemplate(JPanel panel, String windowName, String imagePath)
  {
    this(panel, windowName, imagePath, true, 0, 0);
  }

  public FrameTemplate(JPanel panel, String windowName, String imagePath, boolean pack, int width, int height)
  {
    super(windowName);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setContentPane(panel);
    if (pack)
      pack();
    else
      setSize(width, height);
    if (imagePath != null) setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource(imagePath)));
  }

  public FrameTemplate setLocation(boolean relative, Component comp, int x, int y, boolean resizable)
  {
    if (relative)
      setLocationRelativeTo(comp);
    else
      setLocation(x, y);
    setResizable(resizable);
    return this;
  }

  public FrameTemplate showFrame(boolean flag)
  {
    setVisible(flag);
    return this;
  }
}
